#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll t;
ll d[100007],v[100007],a[100007];
bool vis[100007];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        memset(vis,false,sizeof(vis));
        ll ans1=0;
        ll n,m,l,V;
        cin>>n>>m>>l>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            ll x;
            cin>>x;
            for(int j=1;j<=n;j++){
                if(!vis[j]&&x<=d[j]&&sqrt(v[j]*v[j]+2*a[j]*(x-d[j]))>V){
                    ans1++;
                    vis[j]=true;
                }
            }
        }
        cout<<ans1<<" "<<0<<endl;
    }
    return 0;
}
